#!/usr/bin/env python3
# Author: i0gan
# A script for awd loop submit flag

import os
import json
import requests
li = lambda x : print('\x1b[01;38;5;214m' + x + '\x1b[0m')

url = 'http://10.10.101.200/api/v1/att_def/web/submit_flag/?event_id=4'
flag_file = './flags'
header = {
    'Cookie': 'none'
}

def submit():
	with open(flag_file) as flag_txt:
		flags = flag_txt.readlines()
		for flag in flags:
			flag = flag.strip()
			d = 'flag='
			d += flag
			d += '&token=KexQHEuq3tetqMAVYVH3Gk7nkDGHVmamcQ9JDb7tdDRhY'
			print(d)
			try:
				res = requests.post(url,data=d,timeout=2)
				li(res.text)
			except:
				li('connect fail!')
				continue
submit()
